home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / AdjustmentEvent.java < prev    next >
Text File  |  1998-09-22  |  4KB  |  154 lines

  1. /*
  2.  * @(#)AdjustmentEvent.java    1.12 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.event;
  16.  
  17. import java.awt.Adjustable;
  18. import java.awt.AWTEvent;
  19. import java.awt.Event;
  20.  
  21. /**
  22.  * The adjustment event emitted by Adjustable objects.
  23.  * @see java.awt.Adjustable
  24.  * @see AdjustmentListener
  25.  *
  26.  * @version 1.12 07/01/98
  27.  * @author Amy Fowler
  28.  */
  29. public class AdjustmentEvent extends AWTEvent {
  30.  
  31.     /**
  32.      * Marks the first integer id for the range of adjustment event ids.
  33.      */
  34.     public static final int ADJUSTMENT_FIRST     = 601;
  35.  
  36.     /**
  37.      * Marks the last integer id for the range of adjustment event ids.
  38.      */
  39.     public static final int ADJUSTMENT_LAST     = 601;
  40.  
  41.     /**
  42.      * The adjustment value changed event.
  43.      */
  44.     public static final int ADJUSTMENT_VALUE_CHANGED = ADJUSTMENT_FIRST; //Event.SCROLL_LINE_UP
  45.  
  46.     /**
  47.      * The unit increment adjustment type.
  48.      */
  49.     public static final int UNIT_INCREMENT    = 1;
  50.  
  51.     /**
  52.      * The unit decrement adjustment type.
  53.      */
  54.     public static final int UNIT_DECREMENT    = 2;
  55.  
  56.     /**
  57.      * The block decrement adjustment type.
  58.      */
  59.     public static final int BLOCK_DECREMENT     = 3;
  60.  
  61.     /**
  62.      * The block increment adjustment type.
  63.      */
  64.     public static final int BLOCK_INCREMENT     = 4;
  65.  
  66.     /**
  67.      * The absolute tracking adjustment type.
  68.      */
  69.     public static final int TRACK            = 5;
  70.  
  71.     Adjustable adjustable;
  72.     int value;
  73.     int adjustmentType;
  74.  
  75.     /*
  76.      * JDK 1.1 serialVersionUID 
  77.      */
  78.      private static final long serialVersionUID = 5700290645205279921L;
  79.  
  80.     /**
  81.      * Constructs a AdjustmentEvent object with the specified Adjustable source,
  82.      * type, and value.
  83.      * @param source the Adjustable object where the event originated
  84.      * @id the event type
  85.      * @type the adjustment type 
  86.      * @value the current value of the adjustment
  87.      */
  88.     public AdjustmentEvent(Adjustable source, int id, int type, int value) {
  89.         super(source, id);
  90.     adjustable = source;
  91.         this.adjustmentType = type;
  92.     this.value = value;
  93.     }
  94.  
  95.     /**
  96.      * Returns the Adjustable object where this event originated.
  97.      */
  98.     public Adjustable getAdjustable() {
  99.         return adjustable;
  100.     }
  101.  
  102.     /**
  103.      * Returns the current value in the adjustment event.
  104.      */
  105.     public int getValue() {
  106.         return value;
  107.     }
  108.  
  109.     /**
  110.      * Returns the type of adjustment which caused the value changed
  111.      * event.
  112.      * @see UNIT_INCREMENT
  113.      * @see UNIT_DECREMENT
  114.      * @see BLOCK_INCREMENT
  115.      * @see BLOCK_DECREMENT
  116.      * @see TRACK
  117.      */
  118.     public int getAdjustmentType() {
  119.         return adjustmentType;
  120.     }
  121.  
  122.     public String paramString() {
  123.         String typeStr;
  124.         switch(id) {
  125.           case ADJUSTMENT_VALUE_CHANGED:
  126.               typeStr = "ADJUSTMENT_VALUE_CHANGED";
  127.               break;
  128.           default:
  129.               typeStr = "unknown type";
  130.         }
  131.         String adjTypeStr;
  132.         switch(adjustmentType) {
  133.           case UNIT_INCREMENT:
  134.               adjTypeStr = "UNIT_INCREMENT";
  135.               break;
  136.           case UNIT_DECREMENT:
  137.               adjTypeStr = "UNIT_DECREMENT";
  138.               break;
  139.           case BLOCK_INCREMENT:
  140.               adjTypeStr = "BLOCK_INCREMENT";
  141.               break;
  142.           case BLOCK_DECREMENT:
  143.               adjTypeStr = "BLOCK_DECREMENT";
  144.               break;
  145.           case TRACK:
  146.               adjTypeStr = "TRACK";
  147.               break;
  148.           default:
  149.               adjTypeStr = "unknown type";
  150.         }
  151.         return typeStr + ",adjType="+adjTypeStr + ",value="+value;
  152.     }
  153. }
  154.